@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion

echo ===============================================================================
echo            医学文献智能识别与检索系统 - 一键启动脚本
echo ===============================================================================
echo.
echo 注意事项：
echo 1. 请确保已安装JDK 8+、Maven 3.5+、Node.js 16+、MySQL 8.0+
echo 2. 请确保MySQL服务已启动，并已创建medical_literature_system数据库
echo 3. 请确保Redis和RabbitMQ服务已启动
echo 4. 启动过程中请勿关闭弹出的命令行窗口
echo.
pause

echo.
echo 正在启动Eureka注册中心...
start "Eureka Server" cmd /k "cd /d d:\chengxu\dasishixun\backend\eureka-server && mvn spring-boot:run"

timeout /t 15 /nobreak >nul

echo.
echo 正在启动API网关服务...
start "API Gateway" cmd /k "cd /d d:\chengxu\dasishixun\backend\api-gateway && mvn spring-boot:run"

timeout /t 15 /nobreak >nul

echo.
echo 正在启动用户服务...
start "User Service" cmd /k "cd /d d:\chengxu\dasishixun\backend\user-service && mvn spring-boot:run"

timeout /t 15 /nobreak >nul

echo.
echo 正在启动文献服务...
start "Document Service" cmd /k "cd /d d:\chengxu\dasishixun\backend\document-service && mvn spring-boot:run"

timeout /t 15 /nobreak >nul

echo.
echo 正在启动识别服务...
start "Recognition Service" cmd /k "cd /d d:\chengxu\dasishixun\backend\recognition-service && mvn spring-boot:run"

timeout /t 15 /nobreak >nul

echo.
echo 正在启动检索服务...
start "Search Service" cmd /k "cd /d d:\chengxu\dasishixun\backend\search-service && mvn spring-boot:run"

timeout /t 15 /nobreak >nul

echo.
echo 正在启动可视化服务...
start "Visualization Service" cmd /k "cd /d d:\chengxu\dasishixun\backend\visualization-service && mvn spring-boot:run"

timeout /t 15 /nobreak >nul

echo.
echo 正在启动前端应用...
start "Frontend" cmd /k "cd /d d:\chengxu\dasishixun\frontend\medical-literature-frontend && npm run dev"

echo.
echo ===============================================================================
echo 启动完成！请按以下步骤进行测试：
echo 1. 访问 Eureka注册中心: http://localhost:10004
echo 2. 等待所有服务注册完成（约1-2分钟）
echo 3. 访问前端应用: http://localhost:5173
echo 4. 使用默认管理员账户登录:
echo    用户名: admin	echo    密码: admin123
echo ===============================================================================
echo.
echo 提示：如需停止所有服务，请运行 stop-all-services.bat
echo.
pause